#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

template<typename T=int>
inline T read() {
    T x;
    cin >> x;
    return x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n = read(), b = read();
    vector<int> a((istream_iterator<int>(cin)),
                  istream_iterator<int>());
    sort(a.begin(), a.end());
    a.erase(remove_if(a.begin(), a.end(), [b](const int x) {
                return x % b == 0;
            }),
            a.end());
    for_each(a.begin(), a.end(), [](const int x) {
        if (isupper(x))cout << char(x) << " ";
        else cout << x << " ";
    });
    return 0;
}
//酷炫灿烂的STL用法:)